<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>定时器1</title>
   <script>
      window.onload=function(){
	    var oBtn1=document.getElementById("open");
		var oBtn2=document.getElementById("close");
		var timer=null;
		
		oBtn1.onclick=function(){
		   timer=setInterval(function(){
		      alert("a");
		   },3000)
		};
		oBtn2.onclick=function(){
		   clearInterval(timer);
		};
	  };
   </script>
</head>
<body>
  <input type="button" value="开启" id="open">
  <input type="button" value="关闭" id="close">


</body>
</html>